#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e3+100;
typedef int LL;
typedef pair<LL,LL>P;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL fa[maxn],ma[maxn][maxn],dis[maxn][maxn],tot=0;
struct Edge{
    LL u,v,cost;
}edges[maxn*maxn];
vector<P>g[maxn];
bool cmp(Edge A,Edge B){return A.cost<B.cost;}
LL find(LL x){
   if(fa[x]!=x) return fa[x]=find(fa[x]);
   return fa[x];
}
void dfs(LL anc,LL u,LL fa){
     for(LL i=0;i<g[u].size();i++){
        LL v=g[u][i].first;
        LL costt=g[u][i].second;
        if(v==fa) continue;
        dis[anc][v]=dis[anc][u]+costt;
        dfs(anc,v,u);
     }
}
int main(void){
   LL n;n=read();
   bool flag=1;
   for(LL i=1;i<=n;i++){
      for(LL j=1;j<=n;j++){
          ma[i][j]=read();
          edges[++tot].u=i;edges[tot].v=j;edges[tot].cost=ma[i][j];
      }
   }
   for(LL i=1;i<=n;i++){
      for(LL j=1;j<=n;j++){
         if(i==j&&ma[i][j]!=0) flag=0;
         if(i!=j&&ma[i][j]!=ma[j][i]) flag=0;
         if(i!=j&&!ma[i][j]) flag=0;
      }
   }
   if(flag==0){cout<<"NO"<<"\n";return 0;}
   for(LL i=1;i<=n;i++) fa[i]=i;
   sort(edges+1,edges+1+tot,cmp);
   for(LL i=1;i<=tot;i++){
       LL u=edges[i].u;LL v=edges[i].v;LL cost=edges[i].cost;
       if(find(u)!=find(v)){
          fa[find(v)]=find(u);
          g[u].push_back({v,cost});g[v].push_back({u,cost});
       }
   }
   for(LL i=1;i<=n;i++) dfs(i,i,-1);
   for(LL i=1;i<=tot;i++){
       LL u=edges[i].u;LL v=edges[i].v;LL cost=edges[i].cost;
       if(cost!=dis[u][v]||cost!=dis[v][u]){
          flag=0;break;
       }
   }
//   for(LL i=1;i<=n;i++){
//       cout<<"\n";
//       for(LL j=1;j<=n;j++){
//           cout<<dis[i][j]<<" ";
//       }
//       cout<<"\n";
//   }
   if(flag==1){
      cout<<"YES"<<"\n";
   }
   else cout<<"NO"<<"\n";
   return 0;
}
